<%@ page import="com.h.heal.entity.Admin" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="zh">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>HEAL编辑文章</title>
   <jsp:include page="../../common_css.jsp"/>

    <style>
        .form-control{
            width: 30%;
        }
    </style>
</head>
<body style="background: linear-gradient(to top right, #a1ffce 0%, #faffd1 100%);">
<div class="container-scroller">
    <!-- partial:partials/_navbar.html -->
    <jsp:include page="../../top.jsp"/>

    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
        <!-- partial:partials/_sidebar.html -->
        <jsp:include page="../../left.jsp"/>
        <!-- partial -->
        <div class="main-panel">
                <div class="row">
                    <div class="col-md-12 stretch-card">
                        <div class="card"style="background: rgba(255,255,255,0);
    border: none;">
                            <div class="card-body">

                                <div class="table-responsive" align="center">


                                    <form id="frm" class="form-signin">
<%--                                        <img class="mb-4" src="${pageContext.request.contextPath}/style/images/Logo with Inverted Palette - No Background.png" alt="" width="50" height="50">--%>
                                        <h1 class="h3 mb-3 font-weight-normal">编辑文章信息</h1>
                                        <label for="input_topic_tid" class="sr-only">文章tid</label>
<%--              获得产品编号                          value="${product.product_id}--%>
                                        <input type="text" id="input_topic_tid" name="topic_tid" class="form-control"  value="${topic.topic_tid}"  placeholder="tid" readonly>

                                        <label for="input_topic_title" class="sr-only">文章标题</label>
                                        <input type="text" id="input_topic_title"  name="topic_title" class="form-control" value="${topic.topic_title}"  placeholder="topic_title" >

                                        <label for="input_topic_uid" class="sr-only">作者UID</label>
                                        <input type="text" id="input_topic_uid" name="topic_uid" class="form-control" value="${topic.topic_uid}"   placeholder="uid" readonly>

                                        <label for="input_topic_timestamp" class="sr-only">发布时间</label>
                                        <input type="text" id="input_topic_timestamp" name="topic_timestamp" class="form-control" value="${topic.topic_timestamp}"   placeholder="timestamp" readonly>

                                        <label for="input_topic_like" class="sr-only">点赞数</label>
                                        <input type="text" id="input_topic_like" name="topic_like"
                                               class="form-control" value="${topic.topic_like}" placeholder="like" readonly>

                                        <label for="input_topic_maintext" class="sr-only">文章内容</label>
                                        <textarea type="text" id="input_topic_maintext" name="topic_maintext" rows="15" cols="40"
                                                class="form-control"  <%--placeholder="topic_maintext"--%>  >${topic.topic_maintext}</textarea>

                                        <button class="btn btn-lg btn-primary btn-block" type="button" onclick="doEdit()" style="width: 30%">编辑</button>
                                    </form>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


           <jsp:include page="../../footer.jsp"/>
        </div>
        <!-- main-panel ends -->
    </div>
    <!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
<jsp:include page="../../common_js.jsp"/>
</body>

</html>

<script>
    function doEdit() {
        //推荐前端js验证字段

        var input_product_id=$("#input_product_id").val();

        if (input_product_id==''){
            alert("产品编号不能为空");
        }else{
            $.ajax(
                {
                    type:"post",
                    url:"/topic/doEdit",
                    data:$("#frm").serialize(),
                    async:false,  //使用ajax同步提交数据
                    success:function (response) {
                        if (response=="ok"){
                            // alert("产品编辑成功,1秒后跳转到产品列表");
                            setTimeout(window.location.href="/topic/main",500);
                        }else{
                            alert("编辑失败，请联系管理员....");
                        }
                    }
                }
            );
        }
    }
</script>

